package com.situ.day1;

import java.util.Scanner;

import org.junit.Test;

public class IfDemo {

	@Test
	public void test1() {
		//int score = 87;
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入学生成绩：");
		//从控制台读入一个整数
		int score = scanner.nextInt();
		
		//将非法情况在前面直接过滤掉
		if (score < 0 || score > 100) {
			System.out.println("输入成绩非法");
			return;//遇到return，整个函数执行结束，后面代码不再执行
		}
		
		if (score >= 90 && score <= 100) {
			System.out.println("优秀");
		} else if (score >= 80 && score < 90) {
			System.out.println("良好");
		} else if (score >= 70 && score < 80) {
			System.out.println("一般");
		} else if (score >= 60 && score < 70) {
			System.out.println("及格");
		} else {
			System.out.println("不及格");
		}
	}
	
	@Test
	public void test4(){
		System.out.println("请输入年份：");
		Scanner sc = new Scanner(System.in);
		int year = sc.nextInt();
		
		if(year < 0){
			System.out.println("输入格式错误！");
			return;
		}
		
		if ((year % 4 == 0 && year % 100 != 0) 
				|| (year % 400 == 0)) {
			System.out.println(year + "是闰年");
		} else {
			System.out.println(year + "不是闰年");
		}
		
	}


	
}
